<?php

/**
 * This is the model class for table "common_district".
 *
 * The followings are the available columns in table 'common_district':
 * @property integer $id ID
 * @property string $name Name
 * @property integer $layer Layer
 * @property integer $usetype Usetype
 * @property integer $parent_id Parent
 * @property integer $sort Sort
 */
class CommonDistrict extends ActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return CommonDistrict the static model class
	 */
	public static function model($className=__CLASS__) {
		return parent::model($className);
	}
	
	public function getMdcClass() {
        return 'application.models.metadata.CommonDistrictMetadata';
    }
    
	static public function cityIds($city) {
		if (empty($city)) return false;
		$model = new self();
		$criteria = new CDbCriteria();
		$criteria->compare('name', $city, true);
		$criteria->addCondition('layer = 1');
		$models = $model->findAll($criteria);
		return CHtml::listData($models, 'id', 'id');
	}
}